package com.ysm.smfu.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.ysm.smfu.R;
import com.ysm.smfu.adapter.DefaultAdapter;
import com.ysm.smfu.bean.BankBean;
import com.ysm.smfu.holder.BankHolder;
import com.ysm.smfu.holder.BaseHolder;
import com.ysm.smfu.utils.UIUtils;

import java.util.List;

/**
 * Created by Administrator on 2016/9/27.
 */
public class MyBankFragment extends MyBaseFragment {

    private List<BankBean> datas;
    private ListView listView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = UIUtils.inflate(R.layout.fragment_bank);
        listView = (ListView) view.findViewById(R.id.fragment_bank_list);
        TextView nobank = (TextView) view.findViewById(R.id.fragment_bank_no_bank);
        if (datas == null) {
            nobank.setVisibility(View.VISIBLE);
            listView.setVisibility(View.GONE);
            return view;
        }
        listView.setVisibility(View.VISIBLE);
        nobank.setVisibility(View.GONE);
        listView.setAdapter(new MyAdapter(datas, listView));
        return view;
    }


    public class MyAdapter extends DefaultAdapter<BankBean> {


        public MyAdapter(List<BankBean> datas, ListView listView) {
            super(datas, listView,null);
        }

        @Override
        protected BaseHolder<BankBean> getHolder() {
            BankHolder bankHolder = new BankHolder(this,MyBankFragment.this);
            return bankHolder;
        }
    }
}
